import { Button, Tooltip, InputNumber, Space, Input, Select, TreeSelect, Row, Col } from 'antd';
import { getColorTextLoadMap, onMouseOutBtn, removeDateHmsStr, renderTableText, tableSorter, tooltipLength, priceFormat } from '@/utils';
import {
  PlusCircleOutlined,
  DeleteOutlined,
  EditOutlined,
  EyeOutlined,
  AppstoreAddOutlined,
  ImportOutlined,
  UploadOutlined,
  SaveOutlined,
} from '@ant-design/icons';
import pageStyles from '@/common/pageLayout.less';
import { getLoadMapList, getSelectDataMapList, getTenantID } from '@/utils';
import { ColumnsRenderFun, DictionaryRenderFun, ILoadMapTypeAll } from '@/common';
import { findObjectById } from '@/utils/findObjectById';
import MyIcon from '@/components/MyIcon';

/** 材料表格 */
const openMaterielColumns = (
  loadMapInfo,
  handleMaterialModal,
  handleAdd,
  delSelectRow,
  pageType,
  selectType,
  handleAssetVisible,
  materielList,
  editTable,
  handleBatchModal,
  isNowCheckPeople,
  isNew,
  checkMaterialList,
  onSelectRadio,
  detailInfo,
) => {
  // 类型
  const assetTypeList = getSelectDataMapList(loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`], 'name', 'id', true);
  // 品牌
  const brandTypeList = getSelectDataMapList(loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_BRAND}`], 'name', 'id', true);
  // 单位
  const midiTypeList = getSelectDataMapList(loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_MIDI}`], 'name', 'id', true);
  // 产权
  const ownershipList = getSelectDataMapList(loadMapInfo?.[`${getTenantID()}${ILoadMapTypeAll.ASSET_EQUITY}`], 'name', 'id', true);

  const isDetail: boolean = pageType == 'detail'; // 是否是查看
  // 资产入库
  const isAssetStore = selectType == '1';

  const disabledFun = (record) => {
    return isDetail || (checkMaterialList.findIndex((item) => item.id === record.id) == -1 && record.id);
  };

  let tableConfig: Record<string, any>[] = [
    {
      title: '物资名称',
      dataIndex: 'assetName',
      key: 'assetName',
      fixed: 'left',
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetName'),
      render: (text: string, record: any, index: number) => {
        return isAssetStore ? (
          <Tooltip title={text}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        ) : (
          <Input
            placeholder="请输入"
            value={text}
            onChange={(e) => {
              editTable({ type: 'assetName', value: e.target.value, index });
            }}
            onMouseOver={(e: Record<string, any>) => (e.target.title = e.target.value)}
            disabled={isDetail || (checkMaterialList.findIndex((item) => item.id === record.id) == -1 && record.id && record.id)}
          />
        );
      },
    },
    {
      title: '物资编号',
      dataIndex: 'materialCode',
      key: 'materialCode',
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'materialCode'),
      render: (text: string, record: any, index: number) => {
        return isAssetStore ? (
          <Tooltip title={text}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        ) : (
          <Input
            placeholder="请输入"
            value={text}
            onChange={(e) => {
              editTable({ type: 'materialCode', value: e.target.value, index });
            }}
            onMouseOver={(e: Record<string, any>) => (e.target.title = e.target.value)}
            disabled={disabledFun(record)}
          />
        );
      },
    },
    {
      title: '物资分类',
      dataIndex: 'assetClass',
      key: 'assetClass',
      width: 200,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetClass'),
      render: (text: string, record: any, index: number) => {
        return (
          <TreeSelect
            value={text}
            style={{ width: '100%' }}
            treeData={assetTypeList}
            fieldNames={{
              label: 'name',
              value: 'id',
              children: 'children',
            }}
            placeholder="请选择"
            disabled={disabledFun(record) || isAssetStore}
            showSearch={true}
            treeNodeFilterProp={'name'}
            allowClear={true}
            onChange={(e) => {
              if (e) {
                editTable({ type: 'assetClass', value: e, index });
              } else {
                editTable({ type: 'assetClass', value: '', index });
              }
            }}
          />
        );
      },
    },
    {
      title: '产权',
      dataIndex: 'ownership',
      key: 'ownership',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'ownership'),
      render: (text: string, record: any, index: number) => {
        return (
          <Select
            value={text}
            style={{ width: '100%' }}
            options={ownershipList}
            fieldNames={{
              label: 'name',
              value: 'value',
            }}
            placeholder="请选择"
            disabled={disabledFun(record) || isAssetStore}
            onSelect={(e) => {
              editTable({ type: 'ownership', value: e, index });
            }}
          />
        );
      },
    },

    {
      title: '规格型号',
      dataIndex: 'paramsInfo',
      key: 'paramsInfo',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'paramsInfo'),
      render: (text: string, record: any, index: number) => {
        return isAssetStore ? (
          <Tooltip title={text}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        ) : (
          <Input
            placeholder="请输入"
            value={text}
            onChange={(e) => {
              editTable({ type: 'paramsInfo', value: e.target.value, index });
            }}
            onMouseOver={(e: Record<string, any>) => (e.target.title = e.target.value)}
            disabled={disabledFun(record)}
          />
        );
      },
    },
    {
      title: '状态',
      dataIndex: 'assetStateName',
      key: 'assetStateName',
      width: 110,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetStateName'),
      render: (text: string) => renderTableText(text, true),
    },
    // {
    //   title: '所属仓库',
    //   dataIndex: 'assetStoreName',
    //   key: 'assetStoreName',
    //   width: 120,
    //   sorter: (a: any, b: any) => tableSorter(a, b, 'assetStoreName'),
    //   render: (text: string) => renderTableText(text, true),
    // },
    {
      title: '数量',
      dataIndex: 'quantityOrArea',
      key: 'quantityOrArea',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'quantityOrArea'),
      render: (text: string, record: any, index: number) => {
        return isAssetStore || record?.id ? (
          <Tooltip title={text}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        ) : (
          <InputNumber
            placeholder="请输入"
            value={text}
            onChange={(e) => {
              editTable({ type: 'quantityOrArea', value: e, index });
            }}
            onMouseOver={(e: Record<string, any>) => (e.target.title = e.target.value)}
            disabled={disabledFun(record)}
            precision={2}
          />
        );
      },
    },
    {
      title: '计量单位',
      dataIndex: 'unitOfMeasurement',
      key: 'unitOfMeasurement',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurement'),
      render: (text: string, record: any, index: number) => {
        return (
          <Select
            value={text}
            style={{ width: '100%' }}
            options={midiTypeList}
            fieldNames={{
              label: 'name',
              value: 'value',
            }}
            placeholder="请选择"
            disabled={disabledFun(record) || isAssetStore}
            onSelect={(e) => {
              editTable({ type: 'unitOfMeasurement', value: e, index });
            }}
          />
        );
      },
    },
    {
      title: '供应商',
      dataIndex: 'supplier',
      key: 'supplier',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'supplier'),
      render: (text, record, index) => {
        return isAssetStore ? (
          <Tooltip title={text || '--'}>
            <span className={pageStyles['over-flow-hidden']}>{text || '--'}</span>
          </Tooltip>
        ) : (
          <Input
            placeholder="请输入"
            value={disabledFun(record) ? record?.assetjson?.supplier : text}
            onChange={(e) => editTable({ type: 'supplier', value: e, index })}
            disabled={disabledFun(record)}
          />
        );
      },
    },
    {
      title: '单价(元)',
      dataIndex: 'assetValue',
      key: 'assetValue',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetValue'),
      render: (text: string, record: any, index: number) => {
        return isAssetStore ? (
          <Tooltip title={text ? priceFormat(text) : `0.0000`}>
            <span className={pageStyles['over-flow-hidden']}>{text ? priceFormat(text) : `0.0000`}</span>
          </Tooltip>
        ) : (
          <InputNumber
            placeholder="请输入"
            value={text}
            onChange={(e) => {
              editTable({ type: 'assetValue', value: e, index });
            }}
            onMouseOver={(e: Record<string, any>) => (e.target.title = e.target.value)}
            disabled={disabledFun(record)}
            precision={4}
          />
        );
      },
    },
    {
      title: '总价(元)',
      dataIndex: 'totalValue',
      key: 'totalValue',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'totalValue'),
      render: (text: number | any) => {
        return (
          <Tooltip title={text ? priceFormat(text) : `0.0000`}>
            <span className={pageStyles['over-flow-hidden']}>{text ? priceFormat(text) : `0.0000`}</span>
          </Tooltip>
        );
      },
    },
    // {
    //   title: '物资来源',
    //   dataIndex: 'sourceTypeName',
    //   key: 'sourceTypeName',
    //   visible: true,
    //   width: 100,
    //   sorter: (a: any, b: any) => tableSorter(a, b, 'sourceTypeName'),
    //   render: (text: string, record: any, index: number) => {
    //     return (
    //       <Input
    //         value={text}
    //         onChange={(e) => {
    //           editTable({ type: 'sourceTypeName', value: e.target.value, index })
    //         }}
    //         disabled={isDetail}
    //       />
    //     )
    //   },
    // },
  ];
  if (pageType != 'detail') {
    tableConfig?.push({
      title: (
        <div style={{ width: '100%', textAlign: 'center' }}>
          {
            <Space>
              {(!detailInfo?.checkState || detailInfo?.checkState !== `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_CHECKRESULT}1002`) && (
                <Button type="link" size="small" icon={<UploadOutlined />} className="manageBtntTxtStyle" onMouseOut={onMouseOutBtn} onClick={handleBatchModal}>
                  导入
                </Button>
              )}
              {materielList.length < 20 && (
                <Tooltip title="超过20条请使用导入">
                  <Button type="link" size="small" icon={<PlusCircleOutlined />} className="manageBtntTxtStyle" onMouseOut={onMouseOutBtn} onClick={handleAdd}>
                    添加行
                  </Button>
                </Tooltip>
              )}
              {!isNew && (
                <Button
                  type="link"
                  size="small"
                  icon={<AppstoreAddOutlined />}
                  className="manageBtntTxtStyle"
                  onMouseOut={onMouseOutBtn}
                  onClick={handleMaterialModal}
                >
                  选择
                </Button>
              )}
            </Space>
          }
        </div>
      ),
      dataIndex: 'otherBtn',
      key: 'otherBtn',
      visible: true,
      width: 260,
      fixed: 'right',
      render: (_text: any, record: any) => {
        return (
          <>
            {selectType == '0' ? (
              <Row justify="center">
                <Col>
                  <Space>
                    {checkMaterialList.findIndex((item) => item.id === record.id) == -1 && record.id && (
                      <Button
                        type="link"
                        size="small"
                        icon={<EditOutlined />}
                        className={'manageBtntTxtStyle'}
                        onMouseOut={onMouseOutBtn}
                        onClick={() => onSelectRadio(record, true)}
                      >
                        修改
                      </Button>
                    )}
                    {record.id && checkMaterialList.findIndex((item) => item.id === record.id) > -1 && (
                      <Button
                        type="link"
                        size="small"
                        icon={<SaveOutlined />}
                        className={'manageBtntTxtStyle'}
                        onMouseOut={onMouseOutBtn}
                        onClick={() => handleAssetVisible('saveMaterial', record)}
                      >
                        保存
                      </Button>
                    )}
                    <Button
                      type="link"
                      size="small"
                      icon={<DeleteOutlined />}
                      className={'manageBtntTxtStyle'}
                      style={{ color: 'red' }}
                      onMouseOut={onMouseOutBtn}
                      onClick={() => delSelectRow(record)}
                    >
                      删除
                    </Button>
                  </Space>
                </Col>
              </Row>
            ) : (
              // {/* <Button
              //   type="link"
              //   size="small"
              //   className={'manageBtntTxtStyle'}
              //   icon={<EditOutlined />}
              //   onMouseOut={onMouseOutBtn}
              //   onClick={handleMaterialModal}
              // >
              //   修改
              // </Button> */}
              <Space>
                <Button
                  type="link"
                  size="small"
                  icon={<EyeOutlined />}
                  className={'manageBtntTxtStyle'}
                  onMouseOut={onMouseOutBtn}
                  onClick={() => {
                    handleAssetVisible('detail', record);
                  }}
                >
                  查看
                </Button>
                <Button
                  type="link"
                  size="small"
                  icon={<EditOutlined />}
                  className={'manageBtntTxtStyle'}
                  onMouseOut={onMouseOutBtn}
                  onClick={() => handleAssetVisible('edit', record)}
                >
                  修改
                </Button>
                <Button
                  type="link"
                  size="small"
                  icon={<DeleteOutlined />}
                  className={'manageBtntTxtStyle'}
                  style={{ color: 'red' }}
                  onMouseOut={onMouseOutBtn}
                  onClick={() => delSelectRow(record)}
                >
                  删除
                </Button>
              </Space>
            )}
          </>
        );
      },
    });
  }
  if (pageType == 'detail' && selectType == '1') {
    tableConfig?.push({
      title: (
        <div style={{ width: '100%', textAlign: 'center' }}>
          {isNowCheckPeople ? (
            <Space>
              {(!detailInfo?.checkState || detailInfo?.checkState !== `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_CHECKRESULT}1002`) && (
                <Button type="link" size="small" icon={<UploadOutlined />} className="manageBtntTxtStyle" onMouseOut={onMouseOutBtn} onClick={handleBatchModal}>
                  导入
                </Button>
              )}
            </Space>
          ) : null}
        </div>
      ),
      dataIndex: 'otherBtn',
      key: 'otherBtn',
      visible: true,
      width: 80,
      fixed: 'right',
      render: (_text: any, record: any) => {
        return (
          <>
            <Button
              type="link"
              size="small"
              icon={<EyeOutlined />}
              className={'manageBtntTxtStyle'}
              onMouseOut={onMouseOutBtn}
              onClick={() => handleAssetVisible('detail', record)}
            >
              查看
            </Button>
          </>
        );
      },
    });
  }

  // 如果是资产,才显示品牌
  if (isAssetStore) {
    tableConfig?.splice(4, 0, {
      title: '品牌',
      dataIndex: 'brandType',
      key: 'brandType',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'brandType'),
      render: (text: string, record: any, index: number) => {
        return isAssetStore ? (
          <Tooltip title={text}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        ) : (
          <Input
            placeholder="请输入"
            value={text}
            onChange={(e) => {
              editTable({ type: 'brandType', value: e.target.value, index });
            }}
            onMouseOver={(e: Record<string, any>) => (e.target.title = e.target.value)}
            disabled={disabledFun(record)}
          />
        );
      },
    });
  }
  return tableConfig;
};

/** 表格配置 */
const materialTableConfig = () => {
  return [
    {
      title: '物资名称',
      dataIndex: 'assetName',
      key: 'assetName',
      fixed: 'left',
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '物资分类',
      dataIndex: 'assetClassName',
      key: 'assetClassName',
      fixed: 'left',
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetClassName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '物资编码',
      dataIndex: 'materialCode',
      key: 'materialCode',
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'materialCode'),
      render: (text: string) => renderTableText(text, true),
    },
    // {
    //   title: '关联合同',
    //   dataIndex: 'contractName',
    //   key: 'contractName',
    //   visible: true,
    //   width: 100,
    //   sorter: (a: any, b: any) => tableSorter(a, b, 'contractName'),
    //   render: (text: string) => {
    //     return (
    //       <Tooltip title={text}>
    //         <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
    //       </Tooltip>
    //     );
    //   },
    // },
    {
      title: '规格参数',
      dataIndex: 'paramsInfo',
      key: 'paramsInfo',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'paramsInfo'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '状态',
      dataIndex: 'assetStateName',
      key: 'assetStateName',
      width: 110,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetStateName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '所属仓库',
      dataIndex: 'assetStoreName',
      key: 'assetStoreName',
      width: 110,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetStoreName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '数量',
      dataIndex: 'quantityOrArea',
      key: 'quantityOrArea',
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'quantityOrArea'),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '计量单位',
      dataIndex: 'unitOfMeasurementName',
      key: 'unitOfMeasurementName',
      visible: true,
      width: 150,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurementName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '单价(元)',
      dataIndex: 'assetValue',
      key: 'assetValue',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetValue'),
      render: (text: number | any) => {
        return (
          <Tooltip title={text}>
            <span className={pageStyles['over-flow-hidden']}>{text ? priceFormat(text) : `0.00`}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '总价(元)',
      dataIndex: 'totalValue',
      key: 'totalValue',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'totalValue'),
      render: (text: number | any) => {
        return <span className={pageStyles['over-flow-hidden']}>{text ? priceFormat(text) : `0.00`}</span>;
      },
    },
    {
      title: '品牌',
      dataIndex: 'brandType',
      key: 'brandType',
      visible: true,
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'brandType'),
      render: (text: string) => {
        return <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>;
      },
    },
    {
      title: '资金来源',
      dataIndex: 'projectName',
      key: 'projectName',
      visible: true,
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'projectName'),
      render: (text: string) => renderTableText(text, true),
    },
  ];
};

const applyStorageTableColumns = () => {
  return [
    {
      title: '申请部门/单位',
      dataIndex: 'createDepartmentName',
      key: 'createDepartmentName',
      fixed: 'left',
      width: 150,
      unDrag: true,
      visible: true,
      sorter: (a: any, b: any) => (a?.applyInfo > b?.applyInfo ? 1 : -1),
      render: (text: string, record: any) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '事项名称',
      dataIndex: 'applyTitle',
      key: 'applyTitle',
      fixed: 'left',
      width: 150,
      unDrag: true,
      visible: true,
      sorter: (a: any, b: any) => (a?.applyInfo > b?.applyInfo ? 1 : -1),
      render: (text: string, record: any) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}> {text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '申请人',
      dataIndex: 'createrName',
      key: 'createrName',
      width: 150,
      unDrag: true,
      visible: true,
      sorter: (a: any, b: any) => (a?.createrName > b?.createrName ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{text || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '申请时间',
      dataIndex: 'createTime',
      key: 'createTime',
      width: 150,
      unDrag: true,
      visible: true,
      sorter: (a: any, b: any) => (a?.createTime > b?.createTime ? 1 : -1),
      render: (text: string) => {
        return (
          <Tooltip title={text}>
            <div className={pageStyles['over-flow-hidden']}>{removeDateHmsStr(text) || '--'}</div>
          </Tooltip>
        );
      },
    },
    {
      title: '状态',
      dataIndex: 'stateName',
      key: 'stateName',
      width: 150,
      unDrag: true,
      visible: true,
      sorter: (a: any, b: any) => (a?.stateName > b?.stateName ? 1 : -1),
      render: (text: number) => {
        let colorText = getColorTextLoadMap(text)?.colorText;
        let color = getColorTextLoadMap(text)?.color;
        return (
          <Tooltip>
            <MyIcon type="icon-dian" style={{ color: color }} />
            <span style={{ color: color }}>{colorText ? colorText : '--'}</span>
          </Tooltip>
        );
      },
    },
  ];
};

// OA页面表格list 配置项
const openMaterielColumnsForOA = ({ handleBatchModal, infoObj }) => {
  let tableConfig: Record<string, any>[] = [
    {
      title: '物资名称',
      dataIndex: 'assetName',
      key: 'assetName',
      fixed: 'left',
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetName'),
      render: (text: string, record: any, index: number) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '物资编号',
      dataIndex: 'materialCode',
      key: 'materialCode',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'materialCode'),
      render: (text: string, record: any, index: number) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '物资分类',
      dataIndex: 'assetClassName',
      key: 'assetClassName',
      width: 200,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetClassName'),
      render: (text: string, record: any, index: number) => DictionaryRenderFun({ text, isTooltip: true }),
    },
    {
      title: '产权',
      dataIndex: 'ownership',
      key: 'ownership',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'ownership'),
      render: (text: string, record: any, index: number) => ColumnsRenderFun({ text, isTooltip: true }),
    },

    {
      title: '规格型号',
      dataIndex: 'paramsInfo',
      key: 'paramsInfo',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'paramsInfo'),
      render: (text: string, record: any, index: number) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '状态',
      dataIndex: 'assetStateName',
      key: 'assetStateName',
      width: 110,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetStateName'),
      render: (text: string) => DictionaryRenderFun({ text, isTooltip: true }),
    },
    // {
    //   title: '所属仓库',
    //   dataIndex: 'assetStoreName',
    //   key: 'assetStoreName',
    //   width: 110,
    //   sorter: (a: any, b: any) => tableSorter(a, b, 'assetStoreName'),
    //   render: (text: string) => renderTableText(text, true),
    // },
    {
      title: '数量',
      dataIndex: 'quantityOrArea',
      key: 'quantityOrArea',
      width: 100,
      sorter: (a: any, b: any) => tableSorter(a, b, 'quantityOrArea'),
      render: (text: string, record: any, index: number) => {
        return (
          <Tooltip title={text}>
            <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '计量单位',
      dataIndex: 'unitOfMeasurementName',
      key: 'unitOfMeasurementName',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurementName'),
      render: (text: string, record: any, index: number) => DictionaryRenderFun({ text, isTooltip: true }),
    },
    {
      title: '供应商',
      dataIndex: 'supplier',
      key: 'supplier',
      visible: true,
      width: 140,
      render: (text, record, index) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '单价(元)',
      dataIndex: 'assetValue',
      key: 'assetValue',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetValue'),
      render: (text: string, record: any, index: number) => {
        return (
          <Tooltip title={text}>
            <span className={pageStyles['over-flow-hidden']}>{text ? priceFormat(text) : `0.00`}</span>
          </Tooltip>
        );
      },
    },
    {
      title: '总价(元)',
      dataIndex: 'totalValue',
      key: 'totalValue',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'totalValue'),
      render: (text: number | any) => {
        return (
          <Tooltip title={text}>
            <span className={pageStyles['over-flow-hidden']}>{text ? priceFormat(text) : `0.00`}</span>
          </Tooltip>
        );
      },
    },
  ];

  // 如果是资产,才显示品牌
  if (infoObj?.materialType == '1') {
    tableConfig?.splice(4, 0, {
      title: '品牌',
      dataIndex: 'brandType',
      key: 'brandType',
      visible: true,
      width: 140,
      sorter: (a: any, b: any) => tableSorter(a, b, 'brandType'),
      render: (text: string, record: any, index: number) => ColumnsRenderFun({ text, isTooltip: true }),
    });
  }

  // if (
  //   infoObj?.checkState !== `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_CHECKRESULT}1002` &&
  //   infoObj?.state !== `${getTenantID()}${ILoadMapTypeAll.ENTER_STORE_STATUS}1003`
  // ) {
  //   tableConfig?.push({
  //     title: (
  //       <div style={{ width: '100%', textAlign: 'center' }}>
  //         <Space>
  //           <Button type="link" size="small" icon={<UploadOutlined />} className="manageBtntTxtStyle" onMouseOut={onMouseOutBtn} onClick={handleBatchModal}>
  //             导入
  //           </Button>
  //         </Space>
  //       </div>
  //     ),
  //     dataIndex: 'otherBtn',
  //     key: 'otherBtn',
  //     visible: true,
  //     width: 80,
  //     fixed: 'right',
  //   });
  // }

  return tableConfig;
};

export { materialTableConfig, openMaterielColumns, applyStorageTableColumns, openMaterielColumnsForOA };
